<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>数据字典项 - TyFast Platform</title>
</head>
<body>
  <!--/* 数据字典项代码片段 */-->
  <th:block th:fragment="items">
    <!-- 右侧抽屉窗口 :: 字典项列表 -->
    <v-navigation-drawer :order="-1" v-model="winDrawer" temporary floating location="right" :width="winDrawerWidth">
      <v-layout full-height>
        <v-sheet class="w-100 overflow-auto">
          <v-app-bar flat color="indigo-darken-2">
            <v-toolbar-title class="text-subtitle-1 font-weight-bold">{{currentName}} :: {{$t('字典项列表')}}</v-toolbar-title>
            <v-spacer></v-spacer>
            <v-btn icon="mdi-close" @click="closeWinDrawer"></v-btn>
          </v-app-bar>
          <v-card flat tile :loading="loading" class="mt-16 mb-8">
            <v-container class="pt-0 px-0">
              <!-- 字典项数据列表 -->
              <v-data-table-server
                  :loading="loading"
                  :headers="datatableItems.headers"
                  :items="datatableItems.items"
                  item-value="value"
                  hide-default-footer
                  hover
              >
                <template #top shiro:hasPermission="/system/dict/item/merge">
                  <v-row>
                    <v-col>
                      <v-btn color="info" class="mt-1 ml-2 pr-5 pl-4" @click="openWinFormDrawer('新增字典项')">
                        <v-icon size="small">mdi-plus</v-icon>
                        {{$t('新增')}}
                      </v-btn>
                    </v-col>
                  </v-row>
                </template>
                <template v-slot:item.operation="{item, index}" shiro:hasPermission="/system/dict/item/merge">
                  <a class="mr-2" @click="openWinFormDrawer('修改字典项', item, index)">{{$t('修改')}}</a>
                  <v-btn-confirm :data="index" @confirm="doDeleteItem"></v-btn-confirm>
                </template>
              </v-data-table-server>
            </v-container>
          </v-card>
        </v-sheet>
        <v-footer app class="border-t-thin justify-end">
          <v-btn variant="outlined" @click="closeWinDrawer">{{$t('关闭')}}</v-btn>
        </v-footer>
      </v-layout>
    </v-navigation-drawer>

    <!-- 右侧抽屉窗口 :: 字典项表单 -->
    <v-navigation-drawer :order="-2" v-model="winFormDrawer" persistent temporary floating location="right" :width="winFormDrawerWidth">
      <v-layout full-height>
        <tform as="v-form" ref="itemDataForm" class="w-100 overflow-auto" @submit="doItemSubmit">
          <v-sheet class="w-100">
            <v-app-bar flat color="indigo-darken-2">
              <v-toolbar-title class="text-subtitle-1 font-weight-bold">{{$t(drawerTitle)}}</v-toolbar-title>
              <v-spacer></v-spacer>
              <v-btn icon="mdi-close" :disabled="posting" @click="closeWinFormDrawer"></v-btn>
            </v-app-bar>
            <v-card flat tile :loading="loading" class="mt-16 mb-8">
              <v-container class="pt-0">
                <tfield v-model.trim="formDataItem.title" name="字典项名称" v-slot="{ field, errors }" rules="required|max:30">
                  <v-text-field v-bind="field" :model-value="field.value" clearable v-blank type="text" :error-messages="errors" :label="$t('字典项名称')" class="mt-4"></v-text-field>
                </tfield>
                <tfield v-model.trim="formDataItem.value" name="值" v-slot="{ field, value, errors }" rules="required|max:500|check:checkItemValue">
                  <v-text-field v-if="!value || typeof(value)=='number' || value?.length < 80" v-bind="field" :model-value="field.value" autofocus clearable v-blank type="text" :error-messages="errors" :label="$t('值')" class="mt-1"></v-text-field>
                  <v-textarea v-if="value?.length >= 80" v-bind="field" :model-value="field.value" autofocus auto-grow clearable v-blank type="text" :error-messages="errors" :label="$t('值')" class="mt-1"></v-textarea>
                </tfield>
              </v-container>
            </v-card>
          </v-sheet>
          <v-footer app class="border-t-thin justify-end">
            <v-btn variant="outlined" class="mr-4" :disabled="posting" @click="closeWinFormDrawer">{{$t('关闭')}}</v-btn>
            <v-btn type="submit" color="info" :loading="posting">{{$t('保存')}}</v-btn>
          </v-footer>
        </tform>
      </v-layout>
    </v-navigation-drawer>

    <!-- 业务js -->
    <script type="text/javascript" th:src="@{/js/system/dict/dict-item.js?_t=#buildtime#}"></script>
  </th:block>
</body>
</html>
